<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Used to modify the behavior of a prepared statement</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="mysqli-stmt.attr-get.html">mysqli_stmt::attr_get</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="mysqli-stmt.bind-param.html">mysqli_stmt::bind_param</a></div>
 <div class="up"><a href="class.mysqli-stmt.html">MySQLi_STMT</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="mysqli-stmt.attr-set" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">mysqli_stmt::attr_set</h1>
  <h1 class="refname">mysqli_stmt_attr_set</h1>
  <p class="verinfo">(PHP 5)</p><p class="refpurpose"><span class="refname">mysqli_stmt::attr_set</span> -- <span class="refname">mysqli_stmt_attr_set</span> &mdash; <span class="dc-title">Used to modify the behavior of a prepared statement</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-mysqli-stmt.attr-set-description">
  <h3 class="title">说明</h3>
  <p class="para">面向对象风格</p>
  <div class="methodsynopsis dc-description">
   <span class="type">bool</span> <span class="methodname"><strong>mysqli_stmt::attr_set</strong></span>
    ( <span class="methodparam"><span class="type">int</span> <code class="parameter">$attr</code></span>
   , <span class="methodparam"><span class="type">int</span> <code class="parameter">$mode</code></span>
   )</div>

  <p class="para rdfs-comment">过程化风格</p>
  <div class="methodsynopsis dc-description">
   <span class="type">bool</span> <span class="methodname"><strong>mysqli_stmt_attr_set</strong></span>
    ( <span class="methodparam"><span class="type"><a href="class.mysqli-stmt.html" class="type mysqli_stmt">mysqli_stmt</a></span> <code class="parameter">$stmt</code></span>
   , <span class="methodparam"><span class="type">int</span> <code class="parameter">$attr</code></span>
   , <span class="methodparam"><span class="type">int</span> <code class="parameter">$mode</code></span>
   )</div>

  <p class="para rdfs-comment">
   Used to modify the behavior of a prepared statement. This function may be
   called multiple times to set several attributes.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-mysqli-stmt.attr-set-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>
<dt>
<em><code class="parameter">
stmt</code></em></dt>
<dd>
<p class="para">仅以过程化样式：由
<span class="function"><a href="mysqli.stmt-init.html" class="function">mysqli_stmt_init()</a></span> 返回的 statement 标识。</p></dd>

     <dt>
<em><code class="parameter">attr</code></em></dt>

     <dd>

      <p class="para">
       The attribute that you want to set. It can have one of the following values:
       <table class="doctable table">
        <caption><strong>Attribute values</strong></caption>
        
         <thead>
          <tr>
           <th>Character</th>
           <th>Description</th>
          </tr>

         </thead>

         <tbody class="tbody">
          <tr>
           <td>MYSQLI_STMT_ATTR_UPDATE_MAX_LENGTH</td>
           <td>
            If set to 1, causes <span class="function"><a href="mysqli-stmt.store-result.html" class="function">mysqli_stmt_store_result()</a></span> to
            update the metadata <em>MYSQL_FIELD-&gt;max_length</em> value.
           </td>
          </tr>

          <tr>
           <td>MYSQLI_STMT_ATTR_CURSOR_TYPE</td>
           <td>
            Type of cursor to open for statement when <span class="function"><a href="mysqli-stmt.execute.html" class="function">mysqli_stmt_execute()</a></span>
            is invoked. <em><code class="parameter">mode</code></em> can be <em>MYSQLI_CURSOR_TYPE_NO_CURSOR</em>
            (the default) or <em>MYSQLI_CURSOR_TYPE_READ_ONLY</em>.
           </td>
          </tr>

          <tr>
           <td>MYSQLI_STMT_ATTR_PREFETCH_ROWS</td>
           <td>
            Number of rows to fetch from server at a time when using a cursor.
            <em><code class="parameter">mode</code></em> can be in the range from 1 to the maximum
            value of unsigned long. The default is 1.
           </td>
          </tr>

         </tbody>
        
       </table>

      </p>
      <p class="para">
       If you use the <em>MYSQLI_STMT_ATTR_CURSOR_TYPE</em> option with
       <em>MYSQLI_CURSOR_TYPE_READ_ONLY</em>, a cursor is opened for the
       statement when you invoke <span class="function"><a href="mysqli-stmt.execute.html" class="function">mysqli_stmt_execute()</a></span>. If there
       is already an open cursor from a previous <span class="function"><a href="mysqli-stmt.execute.html" class="function">mysqli_stmt_execute()</a></span> call,
       it closes the cursor before opening a new one. <span class="function"><a href="mysqli-stmt.reset.html" class="function">mysqli_stmt_reset()</a></span>
       also closes any open cursor before preparing the statement for re-execution.
       <span class="function"><a href="mysqli-stmt.free-result.html" class="function">mysqli_stmt_free_result()</a></span> closes any open cursor.
      </p>
      <p class="para">
       If you open a cursor for a prepared statement, <span class="function"><a href="mysqli-stmt.store-result.html" class="function">mysqli_stmt_store_result()</a></span>
       is unnecessary.
      </p>
     </dd>

    
    
     <dt>
<em><code class="parameter">mode</code></em></dt>

     <dd>

      <p class="para">The value to assign to the attribute.</p>
     </dd>

    
   </dl>

  </p>
 </div>

</div><hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="mysqli-stmt.attr-get.html">mysqli_stmt::attr_get</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="mysqli-stmt.bind-param.html">mysqli_stmt::bind_param</a></div>
 <div class="up"><a href="class.mysqli-stmt.html">MySQLi_STMT</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>
